package com.ty.xiaoyu.service.impl;

import com.ty.xiaoyu.entity.Module;
import com.ty.xiaoyu.exception.ModuleOperationException;
import com.ty.xiaoyu.service.ModuleService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ModuleServiceImpl extends BaseService implements ModuleService {
    @Override
    public List<Module> getModuleList() throws ModuleOperationException {
        List<Module> moduleList = moduleMapper.queryModuleList();
        if (moduleList == null || moduleList.isEmpty()) {
            throw new ModuleOperationException("未找到模块");
        }
        return moduleList;
    }

    @Override
    public Module getModuleById(String moduleId) throws ModuleOperationException {
        Module module = moduleMapper.queryModuleById(moduleId);
        if (module == null) {
            throw new ModuleOperationException("未找到模块");
        }
        return module;
    }
}
